import { onMounted, onUnmounted } from 'vue'

export function useResize(chartInstance) {
    const resizeHandler = () => {
        chartInstance && chartInstance.resize()
    }

    onMounted(() => {
        window.addEventListener('resize',  resizeHandler)
    })

    onUnmounted(() => {
        window.removeEventListener('resize',  resizeHandler)
    })
}